#include <iostream>
#include <fstream>
#include <ctime>
#include <vector>
using namespace std;
vector<int> bubbleSort(vector<int> arr) {
    for (int i = 0; i < arr.size(); i++) {
        int k = 0;
        for (int j = 0; j < arr.size() - i - 1; j++) {
            if (arr[j] > arr[j + 1]) {
                int t = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = t;
                k++;
            }
        }
        if (k == 0) {
            break;
        }
    }
    return arr;
}
int main() {
    ifstream f1;
    ifstream f2;
    ifstream f3;
    f1.open("m1_sorted.txt");
    f2.open("m2_reverse.txt");
    f3.open("m3_shuffle.txt");
    vector<int> arr;
    int x;
    
    while (f1 >> x) {
        arr.push_back(x);
    }
    double start_tim1 = clock();
    arr = bubbleSort(arr);
    double end_tim1 = clock();
    cout << "m1_sorted " << (end_tim1 - start_tim1) / 1000 << " milliseconds\n";
    
    while (f2 >> x) {
        arr.push_back(x);
    }
    double start_tim2 = clock();
    arr = bubbleSort(arr);
    double end_tim2 = clock();
    cout << "m2_reverse " << (end_tim2 - start_tim2) / 1000 << " milliseconds\n";
    
    while (f3 >> x) {
        arr.push_back(x);
    }
    double start_tim3 = clock();
    arr = bubbleSort(arr);
    double end_tim3 = clock();
    cout << "m3_shuffle " << (end_tim3 - start_tim3) / 1000 << " milliseconds";
}